package cn.edu.zzuli;

import cn.edu.zzuli.pojo.Student;
import cn.edu.zzuli.pojo.User;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("application.xml");
        Student bean = context.getBean(Student.class);
        System.out.println(bean);
    }

    @Test
    public void testSpringCAndP() {
        ApplicationContext context = new ClassPathXmlApplicationContext("application.xml");
        User user = (User) context.getBean("user");
        System.out.println(user);

        User user2 = (User) context.getBean("user2");
        System.out.println(user2);
    }


    @Test
    public void testBeanScope() {
        ApplicationContext context = new ClassPathXmlApplicationContext("application.xml");
        User user = (User) context.getBean("user");
        User user1 = (User) context.getBean("user");
        System.out.println(user == user1);

        User user2 = (User) context.getBean("user2");
        User user3 = (User) context.getBean("user2");
        System.out.println(user2 == user3);
    }
}
